//Player request.
const kPlayVideoReq         = 0;
const kPauseVideoReq        = 1;
const kStopVideoReq         = 2;

//Player response.
const kPlayVideoRsp         = 0;
const kAudioInfo            = 1;
const kVideoInfo            = 2;
const kAudioData            = 3;
const kVideoData            = 4;

//Downloader request.
const kGetFileInfoReq       = 0;
const kDownloadFileReq      = 1;
const kCloseDownloaderReq   = 2;
const KPauseReq             = 3;
const KContinueReq          = 4;
const KSeekToReq            = 5;
const kSpeedReq             = 6;
const kSingleFrameReq       = 7;

//Downloader response.
const kGetFileInfoRsp       = 0;
const kFileData             = 1;
const kWsError              = 2;
const kWsTimeout            = 3;
const kWsSuccess            = 4;
const kWsReconnect          = 5;

//Downloader Protocol.
const kProtoHttp            = 0;
const kProtoWebsocket       = 1;



//Decoder response.
const kInitDecoderRsp       = 0;
const kUninitDecoderRsp     = 1;
const kOpenDecoderRsp       = 2;
const kCloseDecoderRsp      = 3;
const kVideoFrame           = 4;
const kAudioFrame           = 5;
const kStartDecodingRsp     = 6;
const kPauseDecodingRsp     = 7;
const kDecodeFinishedEvt    = 8;
const kRequestDataEvt       = 9;
const kSeekToRsp            = 10;

//Parser request.
const kInitParserReq       = 0;
const kUninitParserReq     = 1;
const kOpenParserReq       = 2;
const kCloseParserReq      = 3;
const kFeedDataReq         = 4;

//Parser response.
const kInitParserRsp       = 0;
const kUninitParserRsp     = 1;
const kOpenParserRsp       = 2;
const kCloseParserRsp      = 3;


//Renderer request.
const kInitRendererReq      = 0;
const kUninitRendererReq    = 1;
const kOpenRendererReq      = 2;
const kCloseRendererReq     = 3;
const kFeedRendererDataReq  = 4;


//Renderer response.
const kInitRendererRsp      = 0;
const kUninitRendererRsp    = 1;
const kOpenRendererRsp      = 2;
const kCloseRendererRsp     = 3;



//Downloader Message Command
const kHeartCommand         = 1;
const kSeekCommand          = 2;
const kPauseCommand         = 3;
const kSpeedCommand         = 4;
const kSingleFrameCommand   = 5;

function Logger(module) {
    this.module = module;
}

Logger.prototype.log = function (line) {
    console.log("[" + this.currentTimeStr() + "][" + this.module + "]" + line);
}

Logger.prototype.logError = function (line) {
    console.log("[" + this.currentTimeStr() + "][" + this.module + "][ER] " + line);
}

Logger.prototype.logInfo = function (line) {
    console.log("[" + this.currentTimeStr() + "][" + this.module + "][IF] " + line);
}

Logger.prototype.logDebug = function (line) {
    console.log("[" + this.currentTimeStr() + "][" + this.module + "][DT] " + line);
}

Logger.prototype.currentTimeStr = function () {
    var now = new Date(Date.now());
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var min = now.getMinutes();
    var sec = now.getSeconds();
    var ms = now.getMilliseconds();
    return year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec + ":" + ms;
}

